<?php
/**
 * Created by PhpStorm.
 * User: zouhua
 * Date: 2017/6/19
 * Time: 17:56
 */

namespace app\actions;


use app\models\Comment;
use app\models\Like;
use yii\db\ActiveQuery;

class ActivityCommentAction extends UserList {

    public $ajaxRegisterPagination = TRUE;

    public function beforeRun() {
        if (!parent::beforeRun()) {
            return FALSE;
        }

//        $uid = $this->controller->getLikeId();
        $id = $this->getParam('id');
        $own = $this->getParam('own');

        $this->modelClass = Comment::className();
        $this->where = ['own' => $own, 'own_id' => $id, 'parent_id' => 0, 'status' => Comment::STATUS_YES];
        //$this->isArray = TRUE;
        $this->with = ['user', 'children'];

        return TRUE;
    }

    public function render($params = [], $view = NULL) {
        $this->controller->view->title = $this->title;
        if (!isset($params['user'])) {
            $params['user'] = $this->user;
        }
        $view = str_replace('_ajax', '', $view);
        return $this->controller->render($params, $view);
    }
}